CC := g++
CPP_FLAGS := -g -Wall
LIBS := -lpthread

INC_DIR := ./include
SRC_DIR := ./source/KeyRecommender ./source/DictionaryProducer ./source/CacheManager ./source/SearchEngineServer ./source/ThreadPool ./source/TcpServer ./source/WebPageSearch ./source/WebPagePreprocesser
INC_FILE := $(addprefix -I, $(INC_DIR))
CPP_FILE := $(wildcard $(addsuffix /*.cc, $(SRC_DIR)))

OBJS := $(patsubst ./source/%.cc, ./objects/%.o, $(CPP_FILE))
TARGET := SearchEngine Client DictionaryProducerTest

all:$(TARGET)
%:$(OBJS) ./objects/%.o
	$(CC) $(CPP_FLAGS) -o $@ $^ $(INC_FILE) $(LIBS)
./objects/%.o:./source/%.cc
	$(CC) $(CPP_FLAGS) -o $@ -c $^ $(INC_FILE) $(LIBS)

.PHONY:clear rebuild
clear:
	$(RM) $(TARGET) $(OBJS) $(patsubst %, ./objects/%.o, $(TARGET))
rebuild:clear all

.SECONDARY:
